﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HR60_PanelSoft.Model;

namespace HR60_PanelSoft.Service
{
	public class DeviceTypeService
	{
		/// <summary>
		/// 设备创建器
		/// </summary>
		private static DeviceCreator deviceCreator = new DeviceCreator();

		static DeviceTypeService()
		{
			deviceCreator.loadTypes();
		}

		public static DeviceCreator getDeviceCreator()
		{
			return deviceCreator;
		}

		/// <summary>
		/// 根据分类获得列表
		/// </summary>
		/// <param name="category"></param>
		/// <returns></returns>
		public static IDictionary<string, List<DeviceType>> findListSortByGroup()
		{
			IDictionary<string, List<DeviceType>> res = new Dictionary<string, List<DeviceType>>();

			foreach (DeviceType dt in deviceCreator.getTypes())
			{
				if (!res.ContainsKey(dt.group))
				{
					res[dt.group] = new List<DeviceType>();
				}
				res[dt.group].Add(dt);
			}
			return res;
		}

		/// <summary>
		/// 获得分类列表
		/// </summary>
		/// <returns></returns>
		public static string[] getCategorys()
		{
			return new string[]
			{
				"负载类",
				"485类",
				"温控器类"
			};
		}
	}
}
